public without sharing class WeekPlanSalerController {
    public String backId {get; private set;} 
	public String msg {get; private set;} 
	public Boolean isErr {get; private set;} 
	public String dataJson {get; private set;} 
	public String saveJson {get;  set;} 
	private Weekly_Plan__c wp ;
	private Boolean isNew ;
	private Map<String,DataUtil.SObjectBean> stageObjectMap ; 

    public WeekPlanSalerController() {
        stageObjectMap = new Map<String,DataUtil.SObjectBean>();
    	wp = new Weekly_Plan__c();
    	isNew = true;
    }
    public WeekPlanSalerController(ApexPages.StandardController con) {
        stageObjectMap = new Map<String,DataUtil.SObjectBean>();
        wp = new Weekly_Plan__c();
        isNew = true;
    }

    private Map<String,Set<String>>  getFields(){
    	Map<String,Set<String>> fieldsMap  = new  Map<String,Set<String>>();
    	
    		DataUtil.SObjectBean sb = new DataUtil.SObjectBean();

    		sb.title ='';
    		sb.objname = 'Weekly_Plan__c';
    		sb.stype = DataUtil.getSObjectType(sb.objname );
    		if(!isNew)sb.idvalue = wp.Id  ;
    		sb.type = 'base';
    		sb.condition = ' where Id =\''+wp.Id+'\'';
    		stageObjectMap.put(sb.objname,sb );

    		 Set<String>  fields = new Set<String>{'Start_Date__c','End_Date__c','Business_Total__c','Travel_Total__c'};
    		fieldsMap.put(sb.objname , fields);
    	
    	return fieldsMap;

    }
    public void init(){

    	try {
           
        	//dataMap.put('detail',tmp);
    		Map<String,Object>dataMap = new Map<String,Object>();
                  //字段
             Map<String,Set<String>> fieldsmap = getFields();
             //字段详情
             Map<String, List<DataUtil.FieldBean>> fbMap = DataUtil.getFieldsBean(fieldsmap,stageObjectMap);
            
            //字段赋值
             Map<String,List<DataUtil.FieldBean>> fields = DataUtil.setFieldsValue(fbMap,DataUtil.getBaseInfo(fbMap,stageObjectMap) );
           
            dataMap.put('base',fields);
            dataMap.put('baseObject',DataUtil.getBaseObjectMap(stageObjectMap)); 



        	dataJson = EncodingUtil.urlEncode(JSON.serialize(dataMap ),'UTF-8');



   		}catch (Exception e) {
   		    isErr = true ;
    		ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.ERROR ,e.getMessage()));
   		}
    }
}